package tp4.iterators;

import java.util.Iterator;

import tp4.TabContainer;

public class ItCroissant<T> implements Iterator<T> {

	T[] tab;
	protected int current = -1;

	public ItCroissant(T[] tab) {
		super();
		this.tab = tab;
	}

	@Override
	public boolean hasNext() {
		return (current < tab.length - 1);
	}

	@Override
	public T next() {
		return tab[++current];
	}

	public T nextAfter() {
		// i < tab.length - 1 &&
		int index =0;
		if (current == tab.length-1){
			index = tab.length-1;
		} else  {
			index = current +1;
		}
		return tab[index];
	}

	public void modify(T i) {
		tab[current] = i;
	}

	public void modifyAfter(T i) {
		tab[current + 1] = i;
	}

	public T current() {
		return tab[current];
	}

	@Override
	public void remove() {
		tab[current] = null;
	}

}
